import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '预览',
      dataIndex: 'id',
      fixed: 'left',
      width: 50,
      slots: { customRender: 'id' },
    },
    {
      title: '照片的标识符',
      dataIndex: 'phid',
      width: 150,
    },
    {
      title: '照片文件名',
      dataIndex: 'file',
    },
    {
      title: '拍摄时间',
      dataIndex: 'phtm',
      width: 150,
    },
    {
      title: '拍摄点经度',
      width: 150,
      dataIndex: 'long',
    },
    {
      title: '拍摄点纬度',
      width: 150,
      dataIndex: 'lat',
    },
    {
      title: '位置定位平面精度水平',
      width: 150,
      dataIndex: 'dop',
    },
    {
      title: '拍摄点高程',
      width: 150,
      dataIndex: 'alt',
    },
    {
      title: '定位方法',
      width: 150,
      dataIndex: 'mmode',
    },
    {
      title: '定位时观测到的卫星数量',
      width: 150,
      dataIndex: 'sat',
    },
    {
      title: '照片方位角',
      width: 150,
      dataIndex: 'azim',
    },
    {
      title: '照片方位角的参照方向',
      width: 150,
      dataIndex: 'azimr',
    },
    {
      title: '方位角准确程度',
      width: 150,
      dataIndex: 'azimp',
    },
    {
      title: '拍摄距离',
      width: 150,
      dataIndex: 'dist',
    },
    {
      title: '相机俯仰角',
      width: 150,
      dataIndex: 'tilt',
    },
    {
      title: '相机横滚角',
      width: 150,
      dataIndex: 'roll',
    },
    {
      title: '地理国情信息类型代码',
      width: 150,
      dataIndex: 'cc',
    },
    {
      title: '样点地理环境描述',
      width: 150,
      dataIndex: 'remark',
    },
    {
      title: '拍摄者',
      width: 150,
      dataIndex: 'creator',
    },
    {
      title: '35mm等效焦距',
      width: 150,
      dataIndex: 'focal',
    },
    {
      title: '所属工程',
      width: 150,
      dataIndex: 'project',
    },
    {
      title: '拍摄类型',
      width: 150,
      dataIndex: 'datatype',
    },
    {
      title: '照片类型',
      width: 150,
      dataIndex: 'phototype',
    },
  ];
}

export function getBasicShortColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      width: 150,
      dataIndex: 'id',
      sorter: true,
      sortOrder: 'ascend',
    },
  ];
}

export function getMultipleHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
  ];
}

export function getCustomHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
  ];
}
const renderContent = ({ text, index }: { text: any; index: number }) => {
  const obj: any = {
    children: text,
    attrs: {},
  };
  if (index === 9) {
    obj.attrs.colSpan = 0;
  }
  return obj;
};
export function getMergeHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 300,
      customRender: renderContent,
    },
  ];
}
export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => {
  const arr: any = [];
  for (let index = 0; index < itemNumber; index++) {
    arr.push({
      field: `field${index}`,
      label: `字段${index}`,
      component: 'Input',
      colProps: {
        xl: 12,
        xxl: 8,
      },
    });
  }
  return arr;
};
export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    schemas: [
      ...getAdvanceSchema(5),
      {
        field: `field11`,
        label: `Slot示例`,
        component: 'Select',
        slot: 'custom',
        colProps: {
          xl: 12,
          xxl: 8,
        },
      },
    ],
  };
}
export function getBasicData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
      });
    }
    return arr;
  })();
  return data;
}

export function getTreeTableData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
        children: [
          {
            id: `l2-${index}`,
            name: 'John Brown',
            age: `1${index}`,
            no: `${index + 10}`,
            address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
            beginTime: new Date().toLocaleString(),
            endTime: new Date().toLocaleString(),
          },
        ],
      });
    }
    return arr;
  })();

  return data;
}
